<?php 
$localUrlToken = 'catalogproxy';
$catalogUrl = 'http://yourcatalog.edu';
$proxyUrl =  $catalogUrl . substr($_SERVER['REQUEST_URI'], strpos($_SERVER['REQUEST_URI'], $localUrlToken) + strlen($localUrlToken));
$curl = curl_init();
$options = array(
	CURLOPT_URL => $proxyUrl,
	CURLOPT_HEADER => false,
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_CONNECTTIMEOUT => 2
);
curl_setopt_array($curl, $options);
try {
	$result = curl_exec($curl);
	$resultInfo = curl_getinfo($curl);
	if(200 != $resultInfo['http_code'] || 0 == $resultInfo['download_content_length']) {
		$result = '<div class="widgetError">The Catalog Proxy Service is currently unavailable.</div>';
	}
} catch (Exception $e){
	if(Rd_Debug::isEnabled()) {
		print_r($e);
	}
	$result = '<div class="widgetError">The Catalog Proxy Service is currently unavailable.</div>';
}
curl_close($curl);
print(_fixer($result,$catalogUrl));

function _fixer($string, $catalogUrl)
{
	return str_replace( 
		array(
			'href="record/',
			'src="/images/',
			'src="/include/main.js',
			'http://yourcatalog.edu'
		),
		array(
			"href=\"{$catalogUrl}/record/",
			"src=\"{$catalogUrl}/images/",
			"src=\"{$catalogUrl}/include/main.js",
			'https://yourcatalog.edu'
		),
		$string
	);
}
?>